<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!-- 引入基础系列包 -->
<%@include file="../base/frameBase.jsp" %>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title id="tl-system-name">系统-登录</title>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/module/login/css/normalize.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/module/login/css/demo.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/module/login/css/component.css"/>
</head>
<body>
<div class="container demo-1">
    <div class="content">
        <div id="large-header" class="large-header">
            <canvas id="demo-canvas"></canvas>
            <div class="logo_box">
                <h3 id="system-name">后台管理系统</h3>
                <form action="#" name="f" method="post">
                    <div class="input_outer">
                        <span class="u_user"></span> <input name="loginName" class="text"
                                                            style="color: #FFFFFF !important" type="text"
                                                            placeholder="请输入账户">
                    </div>
                    <div class="input_outer">
                        <span class="us_uer"></span> <input name="loginPwd" class="text"
                                                            style="color: #FFFFFF !important; position: absolute; z-index: 100;"
                                                            value="" type="password" placeholder="请输入密码">
                    </div>
                    <div class="mb2">
                        <a class="act-but submit" onclick="loginCheck()"
                           style="color: #FFFFFF">登录</a>
                        <a href="${ctx}/login/registerIndexPage" class="act-goRegister-but submit"
                           style="color: #FFFFFF">没有帐号，去注册?</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div style="text-align:center;">
    <p>
        <a href="http://www.hami6.com" target="_blank">杭州哈密瓜科技有限公司</a><span>  |  </span>
        <a href="http://www.hami6.com" target="_blank">承接小程序 、web系统开发等</a><span>  |  </span>
        <a href="http://www.hami6.com" target="_blank">郑经理</a><span>  |  </span>
        <a href="http://www.hami6.com" target="_blank">15757852723</a>
    </p>
</div>
</body>
<script src="${ctx}/static/module/login/js/TweenLite.min.js"></script>
<script src="${ctx}/static/module/login/js/EasePack.min.js"></script>
<script src="${ctx}/static/module/login/js/rAF.js"></script>
<script src="${ctx}/static/module/login/js/demo-1.js"></script>
<script type="text/javascript">
    var indexPageUrl = "${ctx}/login/adminIndex";
    layui.use('layer', function () {
        var layer = layui.layer;
        initSystemInfo();
    });

    $(document).keydown(function(event){
        if(event.keyCode == 13){ //绑定回车
            this.loginCheck();
        }
    });

    function loginCheck() {
        var loginName = $("input[name='loginName']").val(); //用户名
        var loginPwd = $("input[name='loginPwd']").val();  //注册密码
        if (loginName == null || loginName == "") {
            alert("请输入用户名");
            return;
        }
        if (loginPwd == null || loginPwd == "") {
            alert("请输入密码");
            return;
        }
        var appLoginRequestVO = {};
        $(appLoginRequestVO).attr({
            "loginName": loginName
        });
        $(appLoginRequestVO).attr({
            "password": loginPwd
        });
        $.ajax({
            type: "post",
            url: "${ctx}/loginData/loginUser",
            dataType: "json",
            data: JSON.stringify(appLoginRequestVO),
            async: false,
            contentType: "application/json;charset=utf-8",
            success: function (result) {
                debugger;
                var data = result;
                if (data.code == "00000") {
                    layer.msg("登录成功!");
                    window.location.href = indexPageUrl;
                } else if (data.code == "04007") {
                    layer.msg("用户不存在！");
                    return;
                } else if (data.code == "04010") {
                    layer.msg("用户审核中！请联系管理员加速！");
                    return;
                } else if (data.code == "04012") {
                    layer.msg("该用户审核失败,重新填写信息后注册！");
                    return;
                } else {
                    layer.msg("密码错误，再想想...");
                    return;
                }

            },
            error: function (req, error, errObj) {
            }
        });
    }

    function initSystemInfo(){
        debugger;
        $.ajax({
            type: "get",
            url: "${ctx}/adminManageData/initConfigInfo",
            dataType: "json",
            async: false,
            contentType: "application/json;charset=utf-8",
            success: function (result) {
                debugger;
                var data = result;
                if (data.code == "00000") {
                    debugger;
                  $("#system-name").html(data.data.name);
                  $("#tl-system-name").html(data.data.title+"-login");
                }

            },
            error: function (req, error, errObj) {
            }
        });
    }

</script>
</html>